{include file="public/frame_head"}
<div class="row">
    <div class="col-sm-12">
        <div class="ibox">
            <div class="ibox-title">
                <button type="button" class="btn btn-w-m btn-primary" onclick="$eb.createModalFrame(this.innerText,'{:Url('create')}')">添加产品</button>
            </div>
            <div class="ibox-content">
                <div class="row">
                    <div class="m-b m-l">
                        <form action="" class="form-inline">
                            <select name="is_show" aria-controls="editable" class="form-control input-sm">
                                <option value="">产品状态</option>
                                <option value="1" {eq name="where.is_show" value="1"}selected="selected"{/eq}>上架</option>
                                <option value="0" {eq name="where.is_show" value="0"}selected="selected"{/eq}>下架</option>
                            </select>
                            <select name="is_hot" aria-controls="editable" class="form-control input-sm">
                                <option value="">热卖单品</option>
                                <option value="1" {eq name="where.is_hot" value="1"}selected="selected"{/eq}>是</option>
                                <option value="0" {eq name="where.is_hot" value="0"}selected="selected"{/eq}>否</option>
                            </select>
                            <select name="is_benefit" aria-controls="editable" class="form-control input-sm">
                                <option value="">促销单品</option>
                                <option value="1" {eq name="where.is_benefit" value="1"}selected="selected"{/eq}>是</option>
                                <option value="0" {eq name="where.is_benefit" value="0"}selected="selected"{/eq}>否</option>
                            </select>
                            <select name="is_best" aria-controls="editable" class="form-control input-sm">
                                <option value="">精品推荐</option>
                                <option value="1" {eq name="where.is_best" value="1"}selected="selected"{/eq}>是</option>
                                <option value="0" {eq name="where.is_best" value="0"}selected="selected"{/eq}>否</option>
                            </select>
                            <select name="is_new" aria-controls="editable" class="form-control input-sm">
                                <option value="">首发新品</option>
                                <option value="1" {eq name="where.is_new" value="1"}selected="selected"{/eq}>是</option>
                                <option value="0" {eq name="where.is_new" value="0"}selected="selected"{/eq}>否</option>
                            </select>
                            <div class="input-group">
                                <input type="text" name="store_name" value="{$where.store_name}" placeholder="请输入产品名称或者关键字" class="input-sm form-control" size="38"> <span class="input-group-btn">
                                    <button type="submit" class="btn btn-sm btn-primary"> <i class="fa fa-search" ></i> 搜索</button> </span>
                            </div>
                        </form>
                    </div>

                </div>
                <div class="table-responsive">
                    <table class="table table-striped  table-bordered">
                        <thead>
                        <tr>
                            <th class="text-center">编号</th>
                            <th class="text-center">产品图片</th>
                            <th class="text-center">产品名称</th>
                            <th class="text-center">产品分类</th>
                            <th class="text-center">价格</th>
                            <th class="text-center">产品状态</th>
                            <th class="text-center">热卖单品</th>
                            <th class="text-center">促销单品</th>
                            <th class="text-center">精品推荐</th>
                            <th class="text-center">首发新品</th>
                            <th class="text-center">库存</th>
                            <th class="text-center">点赞</th>
                            <th class="text-center">收藏</th>
                            <th class="text-center">内容</th>
                            <th class="text-center">秒杀</th>
                            <th class="text-center">操作</th>
                            <th class="text-center">评论</th>
                        </tr>
                        </thead>
                        <tbody class="">
                        {volist name="list" id="vo"}
                        <tr>
                            <td class="text-center">
                                {$vo.id}
                            </td>
                            <td class="text-center">
                                <img src="{$vo.image}" alt="{$vo.store_name}" class="open_image" data-image="{$vo.image}" style="width: 50px;height: 50px;cursor: pointer;">
                            </td>
                            <td class="text-center">
                                {$vo.store_name}
                            </td>
                            <td class="text-center">
                                {$vo.cate_name}
                            </td>
                            <td class="text-center">
                                {$vo.price}
                            </td>
                            <td class="text-center">
                                <i class="fa {eq name='vo.is_show' value='1'}fa-check text-navy{else/}fa-close text-danger{/eq}"></i>
                            </td>
                            <td class="text-center">
                                <i class="fa {eq name='vo.is_hot' value='1'}fa-check text-navy{else/}fa-close text-danger{/eq}"></i>
                            </td>
                            <td class="text-center">
                                <i class="fa {eq name='vo.is_benefit' value='1'}fa-check text-navy{else/}fa-close text-danger{/eq}"></i>
                            </td>
                            <td class="text-center">
                                <i class="fa {eq name='vo.is_best' value='1'}fa-check text-navy{else/}fa-close text-danger{/eq}"></i>
                            </td>
                            <td class="text-center">
                                <i class="fa {eq name='vo.is_new' value='1'}fa-check text-navy{else/}fa-close text-danger{/eq}"></i>
                            </td>
                            <td class="text-center">
                                {$vo.stock}
                            </td>
                            <td class="text-center">
                                <span class="btn btn-xs btn-white" {if condition="$vo['collect'] gt 0"}onclick="$eb.createModalFrame('点赞','{:Url('collect',array('id'=>$vo['id']))}')"{/if} style="cursor: pointer">
                                    <i class="fa fa-thumbs-up"></i>&nbsp;&nbsp;{$vo.collect}
                                </span>
                            </td>
                            <td class="text-center">
                                <span class="btn btn-xs btn-white" {if condition="$vo['like'] gt 0"}onclick="$eb.createModalFrame('收藏','{:Url('like',array('id'=>$vo['id']))}')"{/if}  style="cursor: pointer">
                                    <i class="fa fa-heart"></i>&nbsp;&nbsp;{$vo.like}
                                </span>
                            </td>
                            <td class="text-center">
                                <button type="button" class="btn btn-xs btn-primary" onclick="$eb.createModalFrame(this.innerText,'{:Url('edit_content',array('id'=>$vo['id']))}')"><i class="fa fa-pencil"></i> 编辑内容</button>
                            </td>
                            <td class="text-center">
                                <button class="btn btn-success btn-xs" type="button"  onclick="$eb.createModalFrame('开启秒杀','{:Url('seckill',array('id'=>$vo['id']))}')"><i class="fa fa-forumbee"></i> 开启秒杀</button></td>
                            <td class="text-center">
                                <button class="btn btn-default btn-xs" type="button"  onclick="$eb.createModalFrame('属性','{:Url('attr',array('id'=>$vo['id']))}')"><i class="fa fa-shekel"></i> 属性</button>
                                <button class="btn btn-info btn-xs" type="button"  onclick="$eb.createModalFrame('编辑','{:Url('edit',array('id'=>$vo['id']))}')"><i class="fa fa-paste"></i> 编辑</button>
                                <button class="btn btn-warning btn-xs" data-url="{:Url('delete',array('id'=>$vo['id']))}" type="button"><i class="fa fa-warning"></i> 删除
                                </button>
                            </td>
                            <td class="text-center">
                                <a href="{:Url('store.storeProductReply/index',array('product_id'=>$vo['id']))}">查看</a>
                            </td>
                        </tr>
                        {/volist}
                        </tbody>
                    </table>
                </div>
                {include file="public/inner_page"}
            </div>
        </div>
    </div>
    <script>
        $('.btn-warning').on('click',function(){
            window.t = $(this);
            var _this = $(this),url =_this.data('url');
            $eb.$swal('delete',function(){
                $eb.axios.get(url).then(function(res){
                    console.log(res);
                    if(res.status == 200 && res.data.code == 200) {
                        $eb.$swal('success',res.data.msg);
                        _this.parents('tr').remove();
                    }else
                        return Promise.reject(res.data.msg || '删除失败')
                }).catch(function(err){
                    $eb.$swal('error',err);
                });
            })
        });
        $(".open_image").on('click',function (e) {
            var image = $(this).data('image');
            $eb.openImage(image);
        })
    </script>
</div>

{include file="public/inner_footer"}
